package com.pine.app.module.security.core.common;

import lombok.Data;

import java.io.Serializable;

/**
 * 统一客户端返回格式
 *
 * @author dcits.xyjxust
 *         Date 2017年8月23日
 */
@Data
public class Result<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    //状态码
    private Integer code;
    //状态
    private boolean success;
    //信息
    private String message;
    //数据
    private T data;

    public Result() {
    }

    public Result(int code, String message, T data, String url) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.success = (code ==200 ? true : false);
    }

    public static Result build(int code) {
        return build(code, null);
    }

    public static Result build(int code, String message) {
        return build(code, message, null);
    }

    public static Result build(int code, Object data) {
        return build(code, null, data);
    }

    public static Result build(int code, String message, Object data) {
        return  build(code, message, data, null);
    }

    public static Result build(int code, String message, Object data, String url) {
        return new Result(code, message, data, url);
    }


}
